<?php
/**
 * Copyright © 2013-2017 Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

// @codingStandardsIgnoreFile

?>
<?php
/** @var $block \Magento\Backend\Block\Widget\Button\SplitButton */
?>

<div <?php echo $block->getAttributesHtml(); ?>>
    <button <?php echo $block->getButtonAttributesHtml(); ?>>
        <span><?php echo $block->escapeHtml($block->getLabel()); ?></span>
    </button>
    <?php if ($block->hasSplit()): ?>
        <button <?php echo $block->getToggleAttributesHtml() ?>>
            <span>Select</span>
        </button>

        <?php if (!$block->getDisabled()): ?>
            <ul class="dropdown-menu" <?php /* @escapeNotVerified */ echo $block->getUiId("dropdown-menu"); ?>>
                <?php foreach ($block->getOptions() as $key => $option): ?>
                <li>
                    <span <?php echo $block->getOptionAttributesHtml($key, $option); ?>>
                        <?php echo $block->escapeHtml($option['label']); ?>
                    </span>
                    <?php if (isset($option['hint'])): ?>
                    <div class="tooltip" <?php /* @escapeNotVerified */ echo $block->getUiId('item', $key, 'tooltip'); ?>>
                        <a href="<?php echo $block->escapeHtml($option['hint']['href']) ?>" class="help">
                            <?php echo $block->escapeHtml($option['hint']['label']) ?>
                        </a>
                    </div>
                    <?php endif; ?>
                </li>
                <?php endforeach; ?>
            </ul>
        <?php endif; ?>
    <?php endif; ?>
</div>

<script>
require(['jquery'], function($){
        $('.actions-split')
            .on('click.splitDefault', '.action-default', function() {
                $(this).siblings('.dropdown-menu').find('.item-default').trigger('click');
            });
});
</script>
